<template>
    <div>
        <button @click="$router.push('/home')">返回首页</button>
        这是编辑页面
        <input type="text">
    </div>
</template>

<script>
    export default {
        beforeRouteEnter (to, from, next) {
            let Rights = sessionStorage.getItem('myRights')
            if(Rights === 'edit') {
                next()
            }else {
                alert('你没有编辑权限')
            }

        },

        beforeRouteLeave (to, from, next) {
            let flag = confirm('确定要离开吗？')
            if(flag) next()
        }
    }
</script>